<template>
  <div id="container">
    <el-row>
      <el-form :inline="true" :model="role" class="demo-form-inline">
        <el-form-item label="角色名称">
          <el-input v-model="role.roleName" placeholder="请输入角色名称"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="doSaveRole">新增</el-button>
        </el-form-item>
      </el-form>
      <el-table
        size="small"
        :data="rolesList"
        border
        :header-cell-style="tableHeaderColor"
        :cell-style = "cellContentStyle"
        style="margin: 0px auto; width: 60%">
        <el-table-column
          fixed
          prop="rid"
          label="角色编号"
          width="180">
        </el-table-column>
        <el-table-column
          prop="roleName"
          label="角色名称"
          width="200">
        </el-table-column>

        <el-table-column
          fixed="right"
          label="操作"
          width="280">
          <template slot-scope="scope">
            <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
            <el-button type="text" size="small">编辑</el-button>
          </template>
        </el-table-column>
      </el-table>

      <el-row>
        <el-col :span="12" :offset="6" style="margin-top: 10px">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage4"
            :page-sizes="[100, 200, 300, 400]"
            :page-size="100"
            layout="total, sizes, prev, pager, next, jumper"
            :total="400">
          </el-pagination>
        </el-col>
      </el-row>
    </el-row>
  </div>
</template>

<script>
export default {
  name: "roles.vue",
  data(){
    return{
      role:{
        rid: '100',
        roleName: ''
      },
      rolesList:[
        {
          rid: 1,
          roleName: '管理员'
        },
        {
          rid: 2,
          roleName: '普通用户'
        }
      ]
    }
  },
  methods:{
    tableHeaderColor ({row, column, rowIndex, columnIndex}) {
      return 'text-align: center;color: #426ab3'
    },
    cellContentStyle({row, column, rowIndex, columnIndex}){
      return "text-align: center;"
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    doSaveRole(){

    }
  }
}
</script>

<style scoped>
#container {
  margin: 20px 10px;
  padding-right: 20px;
}

.demo-form-inline {
  text-align: center;
}
</style>
